package com.aplikata.evok.datamodel;

import java.util.List;

import javax.faces.model.ListDataModel;

import org.primefaces.model.SelectableDataModel;

import com.aplikata.evok.bo.Qt;
import com.aplikata.evok.service.EvokQtnaireService;
import com.aplikata.service.PublicService;
import com.aplikata.util.StringUtil;

/** 
* @ClassName: QtCategoryDataModel 
* @Description: TODO
* @author Jasenko
* @date 16. 5. 2012. 13:04:40 
*  
*/
public class QtDataModel extends ListDataModel<Qt> implements SelectableDataModel<Qt> {
	private PublicService publicService;
	
	public QtDataModel() {
	}

	public QtDataModel(PublicService publicService, List<Qt> data) {
		super(data);
		this.publicService = publicService;
	}

	@Override
	public Qt getRowData(String arg0) {
		if(StringUtil.isStrEmpty(arg0) || "null".equals(arg0))
			return null;
		
		return (Qt) publicService.get(Qt.class, Long.parseLong(arg0));
	}

	@Override
	public Object getRowKey(Qt qt) {
		return qt.getId();
	}

	public PublicService getPublicService() {
		return publicService;
	}

	public void setPublicService(PublicService publicService) {
		this.publicService = publicService;
	}
}